
<!-- BEGIN:main -->

<script language="javascript" type="text/javascript">
   var loaihoahong=new Array();
   function removeA(arr,value) {
       var loaihoahong_temp = new Array();
       for (var i=0; i<arr.length;i++){           
           if(arr[i]!=value){
               loaihoahong_temp[i] =arr[i] ;
           }
       }
        return loaihoahong_temp;
    }
   

   function addloaihoahong(id,name){
   if(name)
       {
       if(loaihoahong.indexOf(id) == -1)
            loaihoahong[loaihoahong.length] = id;
        } else {     
             loaihoahong=removeA(loaihoahong,id);
           }
          
       }
    function submitTruong(action)
    {

    if(action=='cancel'){
        window.history.back(2);
    }else{
         var BEP_ID = $('#BEP_ID');
         var TRUONG_TEN_TRUONG = $('#TRUONG_TEN_TRUONG');
         
         var arrayInput = new Array(TRUONG_TEN_TRUONG);
        var hasError = validateEmptyValue(arrayInput);
        if (hasError) {
            alert('Vui lòng điền đầy đủ dữ liệu');
        } else {
        var dataString = 'hdAction=' + action;
        dataString += '&BEP_ID=' + BEP_ID.val();
        dataString += '&TRUONG_TEN_TRUONG=' + TRUONG_TEN_TRUONG.val();
          dataString += '&dshoahong=' + loaihoahong;
        $.ajax({
            url: '.?com=com_dm_truong&task=add',
            type: "POST",
            data: dataString,
            cache: false,
            success: function(data) {
                if (data.trim() == 'OK') {
                    alert('Thêm thành công');
                    window.location.href='.?com=com_dm_truong';
                    
                }
            }
        });
        
            }
    }
       


    }
</script> 


<!--biến giá trị hành động-->


<div data-role="content">
   
        <h2><div class="header icon-48-article-add">
                        Trường: <small><small>[ Thêm mới ]</small></small>
                    </div></h2>

        <form method="post" name="phpForm" id="phpForm" action="" class="ui-body ui-body-c ui-corner-all">
           
            <input type="hidden" name="hdAction" id="hdAction" />
            <div data-role="fieldcontain" >
                <label for="name-c" style=" width:150px;display: inline-block; ">Tên trường:</label>
                <input type="text" name="TRUONG_TEN_TRUONG" id="TRUONG_TEN_TRUONG" value=""  />
            </div>

            <div data-role="fieldcontain">
                <label for="name-c" class="select" style=" width:150px;display: inline-block; ">Bếp:</label>
                <select name="BEP_ID" id="BEP_ID" data-theme="c" data-overlay-theme="d" data-native-menu="false">
                    <!-- BEGIN:bep --> 
                    <option value="{BEP_ID}">{BEP_TEN_BEP}</option>
                    <!-- END:bep -->
                </select>
            </div>
            
           <div data-role="fieldcontain" >
               
               <fieldset data-role="controlgroup" >
                    <legend style=" width:150px;">Hoa hồng:</legend>
                <!-- BEGIN:loaihoahong --> 
                <input   onchange="addloaihoahong(this.value,this.checked);" value="{LOAIHOAHONG_ID}" name="checkbox-mini-{LOAIHOAHONG_ID}" id="checkbox-mini-{LOAIHOAHONG_ID}" class="custom" data-mini="true" type="checkbox" >
                <label for="checkbox-mini-{LOAIHOAHONG_ID}">{LOAIHOAHONG_TEN}</label>
               
                <!-- END:loaihoahong -->
                </fieldset>
            </div>

            <div class="ui-body ui-body-b">
                <fieldset class="ui-grid-a">
                    <div class="ui-block-a">
                        <a href="javascript:void()" onclick="submitTruong('cancel');" data-role="button"  data-theme="c">
                            Cancel</a>
                    </div>
                    <div class="ui-block-b">
                        <a href="javascript:void()" onclick="submitTruong('add');" data-role="button"  data-theme="b">
                            Lưu</a>
                    </div>
                    
                </fieldset>
            </div>
        </form>

  




</div>
<div data-role="footer" data-theme="b" data-position="fixed">
    <div class="ui-bar">
        <a href="./?com=com_dm_truong" data-role="button" data-icon="refresh" data-theme="b" style="float:left;">Trở lại</a>
        <!--<a href="javascript:void()" onclick="submitForm11('remove');" data-role="button" data-icon="delete" data-theme="b" style="float:right;" class="returnTopAction">Xóa</a>-->             
    </div>
</div>   



<!-- END:main -->
